//==============================================================================
//
// Title:		CC_Modbus.h
// Purpose:		A short description of the interface.
//
// Created on:	2022/10/28 at 15:18:33 by .
// Copyright:	. All Rights Reserved.
//
//==============================================================================

#ifndef __CC_Modbus_H__
#define __CC_Modbus_H__

#ifdef __cplusplus
    extern "C" {
#endif

//==============================================================================
// Include files
#include <stdint.h>
#include <stdbool.h>
		
#include "cvidef.h"
		
//==============================================================================
// Constants
#ifndef	CC_MODBUS_OK
	#define CC_MODBUS_OK 	0
#endif
#ifndef	CC_MODBUS_NG
	#define CC_MODBUS_NG 	-1
#endif

/***************************** Modbus PDU Size *******************************/
#define MODBUS_MAX_PDU_LENGTH              	253

/***************************** Modbus ADU Size *******************************/ 
#define MODBUS_MAX_ADU_LENGTH              	260

//==============================================================================
// Types

//==============================================================================
// External variables

//==============================================================================
// Global functions
int __declspec(dllexport)__stdcall CC_Modbus_Init(int index, int Port, char Name[], long BaudRate, int Parity, int DataBits, 
		int StopBits, int InputQueueSize, int OutputQueueSize, double OutTime);

int __declspec(dllexport)__stdcall CC_Modbus_Close(int index);

int __declspec(dllexport)__stdcall CC_Modbus_Read_Registers(const int index, const int DeviceAddress, const int Address, const int Size, unsigned int *ReceiveData);
int __declspec(dllexport)__stdcall CC_Modbus_Read_Register(const int index, const int DeviceAddress, const int Address, unsigned int *ReceiveData);

int __declspec(dllexport)__stdcall CC_Modbus_Read_Coils(const int index, const int DeviceAddress, const int Address, const int Size, unsigned int *ReceiveData);
int __declspec(dllexport)__stdcall CC_Modbus_Read_Coil(const int index, const int DeviceAddress, const int Address, unsigned int *ReceiveData);


int __declspec(dllexport)__stdcall CC_Modbus_Write_Coil(const int index, const int DeviceAddress, const int Address, unsigned int *Data, int Length);
int __declspec(dllexport)__stdcall CC_Modbus_Write_Register(const int index, const int DeviceAddress, const int Address, unsigned int *Data, int Length);
int __declspec(dllexport)__stdcall CC_Modbus_Write_Register_With_Feedback(const int index, const int DeviceAddress, const int Address, unsigned int *Data, int Length); 


#ifdef __cplusplus
    }
#endif

#endif  /* ndef __CC_Modbus_H__ */
